import requests

url = "https://www.baidu.com/s"
params = {'wd': 'Python'}  
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
}
response = requests.get(url, params=params, headers=headers)
print(f"状态码：{response.status_code}")
print("内容总长度:", len(response.text))

from bs4 import BeautifulSoup
soup = BeautifulSoup(response.text, 'html.parser')
results = soup.select('.result.c-container')
for i, item in enumerate(results[:3], 1):  
    title = item.select_one('h3').get_text()
    link = item.select_one('a')['href']
    print(f"{i}. {title} {link}")